const express = require('express')
const cors = require('cors')
const morgan = require('morgan')
const router = require('./router')
const errorHandler = require('./middleware/error-handler')
require('dotenv').config({ path: `./config/.env.${process.env.NODE_ENV}` })
require('./model')
const app = express()
app.use(morgan('dev'))
app.use(express.json())
app.use(cors())
app.use(router)
app.use(errorHandler)
const environment = process.env.NODE_ENV;
const PORT = process.env.PORT;
app.listen(PORT, () => {
  console.log(`Server is running at http://localhost: ${PORT}`);
})